package com.shijiwei.lifthelper.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.shijiwei.lifthelper.R;
import com.shijiwei.lifthelper.bean.CookData;
import com.squareup.picasso.Picasso;

import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

import java.util.List;

/**
 * Created by Administrator on 2015/12/16.
 */
public class CookInfoAdapter extends AppBaseAdapter {
    public CookInfoAdapter(List<CookData.StepsEntity> list, Context context) {
        super(list, context);
    }

    @Override
    public View getItemView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null){
            convertView = inflater.inflate(R.layout.item_listview_cook_info,parent,false);
            holder = new ViewHolder(convertView);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.stepImage.setImageResource(R.mipmap.umeng_socialize_share_pic);
        CookData.StepsEntity step = (CookData.StepsEntity) list.get(position);
        holder.stepText.setText(step.getStep());
//        x.image().bind(holder.stepImage,step.getImg());
        Picasso.with(context).load(step.getImg()).into(holder.stepImage);
        return convertView;
    }

    private class ViewHolder extends BaseViewHolder {

        @ViewInject(R.id.iv_item_cook_info)
        private ImageView stepImage;
        @ViewInject(R.id.tv_item_cook_step)
        private TextView stepText;

        public ViewHolder(View convertView) {
            super(convertView);
            x.view().inject(this,convertView);
        }
    }
}
